<template>
	<div class="zk-popup" v-if="diogloFool">
		<div class="zk-popup_bg">
			<div class="zk-popup_h1">此系统要求您登录</div>
			<div class="zk-popup_p">
				<div class="zk-popup_t1">用户名</div>
				<el-input v-model="viewModel.userName" class="zk-popup_ipt" size="medium"></el-input>
			</div>
			<div class="zk-popup_p">
				<div class="zk-popup_t1">密码</div>
				<el-input v-model="viewModel.password" type="password" class="zk-popup_ipt" size="medium"></el-input>
			</div>
			<div class="zk-popup_buts">
				<div class="zk-popup_bt" @click="sumbit">登录</div>
				<div class="zk-popup_bt zk-popup_bt2" @click="diogloFool=false" v-if="false">取消</div>
			</div>
		</div>
	</div>
</template>

<script>
	import './var.scss'

	import ala from 'ala'
	export default {

		data() {
			return {
				viewModel: {},
				diogloFool: true
			}
		},
		mounted() {
			this.init()
		},
		methods: {
			async init() {
				var basicauth = ala.localGet('security_basicauth', true)
				if (basicauth) {
					this.diogloFool = false
				} else {
					this.diogloFool = true
				}
			},
			async sumbit() {
				if (this.viewModel.userName && this.viewModel.password) {
					this.diogloFool = await this.$ala.securityAdminBasicAuth(this.viewModel.userName, this.viewModel.password)
				}
			}
		}
	}
</script>